import 'package:architecture/shared_preference.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:study_demo/base/BaseController.dart';

import '../constant/keys.dart';

final isDarkMode = false.obs;

TextStyle textStyle1 =
    TextStyle(color: isDarkMode.value ? Colors.grey : Colors.black);

toggleTheme() {
  isDarkMode.value = !isDarkMode.value;
  saveInt(THEME_MODE, isDarkMode.value ? 1 : 0);
}

class ThemeController extends BaseController {
  @override
  onInit() {
    super.onInit();
    isDarkMode.value = (readInt(THEME_MODE) ?? 0) == 0 ? false : true;

    print('themeMode:${isDarkMode.value}');
  }
}
